//
//@File    :	14.11_workermi.cpp
//@Time    :	2022/01/25 12:01:00
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	working class methods with
//

#include "14.10_workermi.h"
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

//Worker methods
Worker::~Worker() {}

//protected methods
//模块化方式,在方法中将各个组件组合起来
//Data()方法 只在类内部可用,作为协助公有接口的辅助方法
//所以使用 保护访问
void Worker::Data() const
{
    cout << "Name: " << fullname << endl;
    cout << "Employee ID:" << id << endl;
}

void Worker::Get()
{
    getline(cin, fullname);
    cout << "Enter worker's ID: ";
    cin >> id;
    while (cin.get() != '\n')
    {
        continue;
    }
}

//Waiter methods
void Waiter::Set()
{
    cout << "Enter waiter's name: ";
    //基类Worker和派生类Waiter的Get()方法进行组合
    Worker::Get();
    Get();
}

void Waiter::Show() const
{
    cout << "Category:Waiter\n";
    Worker::Data();
    Data();
}

//protected methods
void Waiter::Data() const
{
    cout << "Panache rating: " << panache << endl;
}

void Waiter::Get()
{
    cout << "Enter waiter's panache rating: ";
    cin >> panache;
    while (cin.get() != 'n')
    {
        continue;
    }
}

//Singer methods
//
//系统报错
//14.11_workermi.cpp:73:75: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
//                                    "soprano", "bass", "baritone", "tenor"};                                                                         ^
//14.11_workermi.cpp:73:75: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
char *Singer::pv[Singer::Vtypes] = {"other", "alto", "contralto",
                                    "soprano", "bass", "baritone", "tenor"};
void Singer::Set()
{
    cout << "Enter singer's name: ";
    Worker::Get();
    Get();
}

void Singer::Show() const
{
    cout << "Category: singer\n";
    Worker::Data();
    Data();
}

//protected methods
void Singer::Data() const
{
    cout << "Vcal range: " << pv[voice] << endl;
}
void Singer::Get()
{
    cout << "Enter number for singer's vocal range:\n";
    int i;
    for (i = 0; i < Vtypes; i++)
    {
        cout << i << ": " << pv[i] << "  ";
        if (i % 4 == 3)
        {
            cout << endl;
        }
    }
    if (i % 4 != 0)
    {
        cout << '\n';
    }
    cin >> voice;
    while (cin.get() != '\n')
    {
        continue;
    }
}

//SingerWaiter methods
void SingerWaiter::Data() const
{
    Singer::Data();
    Waiter::Data();
}
void SingerWaiter::Get()
{
    Waiter::Get();
    Singer::Set();
}

void SingerWaiter::Set()
{
    cout << "ENter singing waier's name: ";
    Worker::Get();
    Get();
}
void SingerWaiter::Show() const
{
    cout << "Category: singing waiter\n";
    Worker::Data();
    Data();
}